<?php

namespace App\Http\Controllers\Api\V2;

use Illuminate\Http\Request;
use App\Http\Requests\ApiV2\FreightSpaceRequest;
use App\Services\Warehouse\Interfaces\FreightSpaceServiceInterface;
use Illuminate\Support\Facades\DB;
use App\Services\Warehouse\Services\FreightSpaceService;

class FreightSpaceController extends BaseController
{
    /**
     * @var FreightSpace
     */
    protected $freightSpaceService;

    public function __construct(FreightSpaceServiceInterface $freightSpaceService)
    {
        $this->freightSpaceService = $freightSpaceService;
    }


    public function index(Request $request)
    {
        $freightSpace = $this->freightSpaceService->index($request->all());
        return $this->data($freightSpace);
    }

    public function store(FreightSpaceRequest $request)
    {
        $this->freightSpaceService->set($request->filldata());
        return $this->success();
    }

    public function edit($id)
    {
        $freightSpace = $this->freightSpaceService->get($id);
        return $this->data($freightSpace);
    }

    public function update(FreightSpaceRequest $request, $id)
    {
        $this->freightSpaceService->set($request->filldata(), $id);
        return $this->success();
    }

    public function destroy($id)
    {
        $this->freightSpaceService->destroy($id);
        return $this->success();
    }

    public function information($position){
        $freightSpace = $this->freightSpaceService->information($position);
        return $this->data($freightSpace);
    }
}
